<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
 * Created on 2012-7-15
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class comment_m extends CI_Model{
 	const TB = 'comments';
 	function __construct(){
 		parent::__construct();
 	}
 	function add_comment($data){
		return $this->db->insert(self::TB,$data);
 	}
 	function get_need_where($need='*',$where){
 		$this->db->select($need);
		$this->db->from(self::TB);
		$this->db->where($where);
		return $this->db->get();
 	}
 	function get_comments_by_articleid($where){
 		$this->db->select('comments.*,users.username');
 		$this->db->from(self::TB);
 		$this->db->join('users','comments.user_id = users.userid');
 		$this->db->where($where);
 		return $this->db->get();
 	}
 }
?>
